package megadrum.gui;

import java.lang.reflect.Method;
import megadrum.*;
import megadrum.mididata.Converter;
import javax.swing.border.TitledBorder;
import javax.swing.JSpinner;
import javax.swing.event.ChangeListener;
import javax.swing.event.ChangeEvent;

public class PadPanel extends javax.swing.JPanel implements ChangeListener {

    public PadPanel(MegadrumConfigTool mct, int pn) {
        this(mct, Common.STEREO_PAD, pn);
    }

    public PadPanel(MegadrumConfigTool mct, int t, int pn) {
        parent = mct;
        padType = t;
        inputNumber = pn;
        initComponents();
        initComponents2();

    }
    //init components (1)
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        headPanel = new javax.swing.JPanel();
        note_H = new javax.swing.JSpinner();
        channel_H = new javax.swing.JSpinner();
        comprLvl_H = new javax.swing.JSpinner();
        lvlShift_H = new javax.swing.JSpinner();
        xtalk_H = new javax.swing.JSpinner();
        xtalkGrp_H = new javax.swing.JSpinner();
        threshold_H = new javax.swing.JSpinner();
        gain_H = new javax.swing.JSpinner();
        hiLvlAuto_H = new javax.swing.JSpinner();
        highLvl_H = new javax.swing.JSpinner();
        retrigger_H = new javax.swing.JSpinner();
        dynLevel_H = new javax.swing.JSpinner();
        dynTime_H = new javax.swing.JSpinner();
        minScan_H = new javax.swing.JSpinner();
        dualHeadType_H = new javax.swing.JSpinner();
        curve_H = new javax.swing.JSpinner();
        thirdZonePanel = new javax.swing.JPanel();
        javax.swing.JLabel label_bNote = new javax.swing.JLabel();
        javax.swing.JLabel jLabel17 = new javax.swing.JLabel();
        bNote = new javax.swing.JSpinner();
        bThreshold = new javax.swing.JSpinner();
        rimPanel = new javax.swing.JPanel();
        note_R = new javax.swing.JSpinner();
        channel_R = new javax.swing.JSpinner();
        comprLvl_R = new javax.swing.JSpinner();
        lvlShift_R = new javax.swing.JSpinner();
        xtalk_R = new javax.swing.JSpinner();
        xtalkGrp_R = new javax.swing.JSpinner();
        threshold_R = new javax.swing.JSpinner();
        gain_R = new javax.swing.JSpinner();
        hiLvlAuto_R = new javax.swing.JSpinner();
        highLvl_R = new javax.swing.JSpinner();
        retrigger_R = new javax.swing.JSpinner();
        dynLevel_R = new javax.swing.JSpinner();
        dynTime_R = new javax.swing.JSpinner();
        minScan_R = new javax.swing.JSpinner();
        dualHeadType_R = new javax.swing.JSpinner();
        curve_R = new javax.swing.JSpinner();

        headPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Head"));

        note_H.setMaximumSize(new java.awt.Dimension(80, 20));
        note_H.setMinimumSize(new java.awt.Dimension(80, 20));

        channel_H.setMaximumSize(new java.awt.Dimension(80, 20));
        channel_H.setMinimumSize(new java.awt.Dimension(80, 20));

        comprLvl_H.setMaximumSize(new java.awt.Dimension(80, 20));
        comprLvl_H.setMinimumSize(new java.awt.Dimension(80, 20));

        lvlShift_H.setMaximumSize(new java.awt.Dimension(80, 20));
        lvlShift_H.setMinimumSize(new java.awt.Dimension(80, 20));

        xtalk_H.setMaximumSize(new java.awt.Dimension(80, 20));
        xtalk_H.setMinimumSize(new java.awt.Dimension(80, 20));

        xtalkGrp_H.setMaximumSize(new java.awt.Dimension(80, 20));
        xtalkGrp_H.setMinimumSize(new java.awt.Dimension(80, 20));

        threshold_H.setMaximumSize(new java.awt.Dimension(80, 20));
        threshold_H.setMinimumSize(new java.awt.Dimension(80, 20));

        gain_H.setMaximumSize(new java.awt.Dimension(80, 20));
        gain_H.setMinimumSize(new java.awt.Dimension(80, 20));

        hiLvlAuto_H.setMaximumSize(new java.awt.Dimension(80, 20));
        hiLvlAuto_H.setMinimumSize(new java.awt.Dimension(80, 20));

        highLvl_H.setMaximumSize(new java.awt.Dimension(80, 20));
        highLvl_H.setMinimumSize(new java.awt.Dimension(80, 20));

        retrigger_H.setMaximumSize(new java.awt.Dimension(80, 20));
        retrigger_H.setMinimumSize(new java.awt.Dimension(80, 20));

        dynLevel_H.setMaximumSize(new java.awt.Dimension(80, 20));
        dynLevel_H.setMinimumSize(new java.awt.Dimension(80, 20));

        dynTime_H.setMaximumSize(new java.awt.Dimension(80, 20));
        dynTime_H.setMinimumSize(new java.awt.Dimension(80, 20));

        minScan_H.setMaximumSize(new java.awt.Dimension(80, 20));
        minScan_H.setMinimumSize(new java.awt.Dimension(80, 20));

        dualHeadType_H.setMaximumSize(new java.awt.Dimension(80, 20));
        dualHeadType_H.setMinimumSize(new java.awt.Dimension(80, 20));

        curve_H.setMaximumSize(new java.awt.Dimension(80, 20));
        curve_H.setMinimumSize(new java.awt.Dimension(80, 20));

        org.jdesktop.layout.GroupLayout headPanelLayout = new org.jdesktop.layout.GroupLayout(headPanel);
        headPanel.setLayout(headPanelLayout);
        headPanelLayout.setHorizontalGroup(
            headPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(headPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(headPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(note_H, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(channel_H, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(curve_H, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(comprLvl_H, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(lvlShift_H, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(xtalk_H, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(xtalkGrp_H, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(threshold_H, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(gain_H, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(hiLvlAuto_H, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(highLvl_H, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(retrigger_H, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(dynLevel_H, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(dynTime_H, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(minScan_H, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(dualHeadType_H, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE))
                .addContainerGap())
        );
        headPanelLayout.setVerticalGroup(
            headPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(headPanelLayout.createSequentialGroup()
                .add(note_H, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(channel_H, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(curve_H, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(comprLvl_H, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(lvlShift_H, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(xtalk_H, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(xtalkGrp_H, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(threshold_H, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(gain_H, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(hiLvlAuto_H, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(highLvl_H, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(retrigger_H, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(dynLevel_H, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(dynTime_H, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(minScan_H, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(dualHeadType_H, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(13, Short.MAX_VALUE))
        );

        thirdZonePanel.setBorder(javax.swing.BorderFactory.createTitledBorder("3rd zone"));

        label_bNote.setText("Bell Note Number");

        jLabel17.setText("Threshold");

        bNote.setMaximumSize(new java.awt.Dimension(80, 20));
        bNote.setMinimumSize(new java.awt.Dimension(80, 20));

        bThreshold.setEnabled(false);
        bThreshold.setMaximumSize(new java.awt.Dimension(80, 20));
        bThreshold.setMinimumSize(new java.awt.Dimension(80, 20));

        org.jdesktop.layout.GroupLayout thirdZonePanelLayout = new org.jdesktop.layout.GroupLayout(thirdZonePanel);
        thirdZonePanel.setLayout(thirdZonePanelLayout);
        thirdZonePanelLayout.setHorizontalGroup(
            thirdZonePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(thirdZonePanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(thirdZonePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, label_bNote)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel17))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(thirdZonePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(bNote, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 80, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(bThreshold, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 80, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        thirdZonePanelLayout.setVerticalGroup(
            thirdZonePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(thirdZonePanelLayout.createSequentialGroup()
                .add(thirdZonePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(label_bNote)
                    .add(bNote, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(thirdZonePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel17)
                    .add(bThreshold, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        rimPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Rim"));

        note_R.setMaximumSize(new java.awt.Dimension(80, 20));
        note_R.setMinimumSize(new java.awt.Dimension(80, 20));

        channel_R.setMaximumSize(new java.awt.Dimension(80, 20));
        channel_R.setMinimumSize(new java.awt.Dimension(80, 20));

        comprLvl_R.setMaximumSize(new java.awt.Dimension(80, 20));
        comprLvl_R.setMinimumSize(new java.awt.Dimension(80, 20));

        lvlShift_R.setMaximumSize(new java.awt.Dimension(80, 20));
        lvlShift_R.setMinimumSize(new java.awt.Dimension(80, 20));

        xtalk_R.setMaximumSize(new java.awt.Dimension(80, 20));
        xtalk_R.setMinimumSize(new java.awt.Dimension(80, 20));

        xtalkGrp_R.setMaximumSize(new java.awt.Dimension(80, 20));
        xtalkGrp_R.setMinimumSize(new java.awt.Dimension(80, 20));

        threshold_R.setMaximumSize(new java.awt.Dimension(80, 20));
        threshold_R.setMinimumSize(new java.awt.Dimension(80, 20));

        gain_R.setMaximumSize(new java.awt.Dimension(80, 20));
        gain_R.setMinimumSize(new java.awt.Dimension(80, 20));

        hiLvlAuto_R.setMaximumSize(new java.awt.Dimension(80, 20));
        hiLvlAuto_R.setMinimumSize(new java.awt.Dimension(80, 20));

        highLvl_R.setMaximumSize(new java.awt.Dimension(80, 20));
        highLvl_R.setMinimumSize(new java.awt.Dimension(80, 20));

        retrigger_R.setMaximumSize(new java.awt.Dimension(80, 20));
        retrigger_R.setMinimumSize(new java.awt.Dimension(80, 20));

        dynLevel_R.setMaximumSize(new java.awt.Dimension(80, 20));
        dynLevel_R.setMinimumSize(new java.awt.Dimension(80, 20));

        dynTime_R.setMaximumSize(new java.awt.Dimension(80, 20));
        dynTime_R.setMinimumSize(new java.awt.Dimension(80, 20));

        minScan_R.setMaximumSize(new java.awt.Dimension(80, 20));
        minScan_R.setMinimumSize(new java.awt.Dimension(80, 20));

        dualHeadType_R.setMaximumSize(new java.awt.Dimension(80, 20));
        dualHeadType_R.setMinimumSize(new java.awt.Dimension(80, 20));

        curve_R.setMaximumSize(new java.awt.Dimension(80, 20));
        curve_R.setMinimumSize(new java.awt.Dimension(80, 20));

        org.jdesktop.layout.GroupLayout rimPanelLayout = new org.jdesktop.layout.GroupLayout(rimPanel);
        rimPanel.setLayout(rimPanelLayout);
        rimPanelLayout.setHorizontalGroup(
            rimPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(rimPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(rimPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, note_R, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, channel_R, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, curve_R, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, comprLvl_R, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, xtalk_R, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, lvlShift_R, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, xtalkGrp_R, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, threshold_R, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, gain_R, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, hiLvlAuto_R, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, highLvl_R, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, retrigger_R, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, dynLevel_R, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, dynTime_R, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, minScan_R, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, dualHeadType_R, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE))
                .addContainerGap())
        );
        rimPanelLayout.setVerticalGroup(
            rimPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(rimPanelLayout.createSequentialGroup()
                .add(note_R, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(channel_R, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(curve_R, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(comprLvl_R, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(lvlShift_R, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(xtalk_R, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(xtalkGrp_R, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(threshold_R, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(gain_R, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(hiLvlAuto_R, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(highLvl_R, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(retrigger_R, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(dynLevel_R, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(dynTime_R, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(minScan_R, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(dualHeadType_R, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(13, Short.MAX_VALUE))
        );

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                .add(headPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(rimPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
            .add(org.jdesktop.layout.GroupLayout.TRAILING, thirdZonePanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                    .add(headPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(rimPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(thirdZonePanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents
    //init components (2)

    private void initComponents2() {
        setPreferredSize(new java.awt.Dimension(234, 535));
        setMaximumSize(new java.awt.Dimension(234, 535));
        setMinimumSize(new java.awt.Dimension(234, 535));

        //configure subpad's names and panels
        if (padType == Common.MONO_PAD) { //MONO PAD
            headPanel.setVisible(false);
            thirdZonePanel.setVisible(false);
            dualHeadType_R.setEnabled(false);
            ((TitledBorder) rimPanel.getBorder()).setTitle("Mono");
        } else { //STEREO PAD
            ((TitledBorder) headPanel.getBorder()).setTitle("Head");
            ((TitledBorder) rimPanel.getBorder()).setTitle("Rim");
        }

        //set data models
        note_H.setModel(new CustomSpinnerNoteModel(0, 0, 127, 1));
        note_R.setModel(new CustomSpinnerNoteModel(0, 0, 127, 1));
        channel_H.setModel(new CustomSpinnerIntModel(10, 1, 16, 1));
        channel_R.setModel(new CustomSpinnerIntModel(10, 1, 16, 1));
        curve_H.setModel(new CustomSpinnerListModel(Common.CURVES));
        curve_H.setValue(Common.CURVES[1]);
        curve_R.setModel(new CustomSpinnerListModel(Common.CURVES));
        curve_R.setValue(Common.CURVES[1]);
        comprLvl_H.setModel(new CustomSpinnerIntModel(0, 0, 7, 1));
        comprLvl_R.setModel(new CustomSpinnerIntModel(0, 0, 7, 1));
        lvlShift_H.setModel(new CustomSpinnerListModel(Common.LEVEL_SHIFT));
        lvlShift_R.setModel(new CustomSpinnerListModel(Common.LEVEL_SHIFT));
        xtalk_H.setModel(new CustomSpinnerIntModel(2, 0, 3, 1));
        xtalk_R.setModel(new CustomSpinnerIntModel(2, 0, 3, 1));
        xtalkGrp_H.setModel(new CustomSpinnerIntModel(0, 0, 3, 1));
        xtalkGrp_R.setModel(new CustomSpinnerIntModel(0, 0, 3, 1));
        threshold_H.setModel(new CustomSpinnerIntModel(30, 0, 127, 1));
        threshold_R.setModel(new CustomSpinnerIntModel(30, 0, 127, 1));
        gain_H.setModel(new CustomSpinnerIntModel(4, 0, 8, 1));
        gain_R.setModel(new CustomSpinnerIntModel(4, 0, 8, 1));
        hiLvlAuto_H.setModel(new CustomSpinnerListModel(Common.NO_YES));
        hiLvlAuto_H.setValue(Common.NO_YES[1]);
        hiLvlAuto_R.setModel(new CustomSpinnerListModel(Common.NO_YES));
        hiLvlAuto_R.setValue(Common.NO_YES[1]);
        highLvl_H.setModel(new CustomSpinnerIntModel(64, 32, 1022, 1));
        highLvl_R.setModel(new CustomSpinnerIntModel(64, 32, 1023, 1));
        retrigger_H.setModel(new CustomSpinnerIntModel(8, 1, 127, 1));
        retrigger_R.setModel(new CustomSpinnerIntModel(8, 1, 127, 1));
        dynLevel_H.setModel(new CustomSpinnerIntModel(6, 0, 7, 1));
        dynLevel_R.setModel(new CustomSpinnerIntModel(6, 0, 7, 1));
        dynTime_H.setModel(new CustomSpinnerListModel(Common.DYN_TIME));
        dynTime_H.setValue(Common.DYN_TIME[2]);
        dynTime_R.setModel(new CustomSpinnerListModel(Common.DYN_TIME));
        dynTime_R.setValue(Common.DYN_TIME[2]);
        minScan_H.setModel(new CustomSpinnerIntModel(20, 1, 100, 1));
        minScan_R.setModel(new CustomSpinnerIntModel(20, 1, 100, 1));
        dualHeadType_H.setModel(new CustomSpinnerListModel(Common.NO_YES_3WAY));
        dualHeadType_R.setModel(new CustomSpinnerListModel(Common.PIEZO_SWITCH));
        bNote.setModel(new CustomSpinnerNoteModel(0, 0, 127, 1));
        bThreshold.setModel(new CustomSpinnerIntModel(0, 0, 127, 1));

        //insert all fields into an array for better managing
        parameter = new JSpinner[2][Common.NUMBER_OF_SUBPAD_PARAMETERS];
        //head parameters
        parameter[0][0] = note_H;
        parameter[0][1] = channel_H;
        parameter[0][2] = curve_H;
        parameter[0][3] = comprLvl_H;
        parameter[0][4] = lvlShift_H;
        parameter[0][5] = xtalk_H;
        parameter[0][6] = xtalkGrp_H;
        parameter[0][7] = threshold_H;
        parameter[0][8] = gain_H;
        parameter[0][9] = hiLvlAuto_H;
        parameter[0][10] = highLvl_H;
        parameter[0][11] = retrigger_H;
        parameter[0][12] = dynLevel_H;
        parameter[0][13] = dynTime_H;
        parameter[0][14] = minScan_H;
        parameter[0][15] = dualHeadType_H;
        //rim & mono parameters
        parameter[1][0] = note_R;
        parameter[1][1] = channel_R;
        parameter[1][2] = curve_R;
        parameter[1][3] = comprLvl_R;
        parameter[1][4] = lvlShift_R;
        parameter[1][5] = xtalk_R;
        parameter[1][6] = xtalkGrp_R;
        parameter[1][7] = threshold_R;
        parameter[1][8] = gain_R;
        parameter[1][9] = hiLvlAuto_R;
        parameter[1][10] = highLvl_R;
        parameter[1][11] = retrigger_R;
        parameter[1][12] = dynLevel_R;
        parameter[1][13] = dynTime_R;
        parameter[1][14] = minScan_R;
        parameter[1][15] = dualHeadType_R;

        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < Common.NUMBER_OF_SUBPAD_PARAMETERS; j++) {
                //set background color to white
                ((JSpinner.DefaultEditor) parameter[i][j].getEditor()).getTextField().setBackground(java.awt.Color.WHITE);
                ((JSpinner.DefaultEditor) parameter[i][j].getEditor()).getTextField().setForeground(java.awt.Color.BLACK);
                //add change listener
                parameter[i][j].addChangeListener(this);
            }
        }
        ((JSpinner.DefaultEditor) bNote.getEditor()).getTextField().setBackground(java.awt.Color.WHITE);
        ((JSpinner.DefaultEditor) bNote.getEditor()).getTextField().setForeground(java.awt.Color.BLACK);
        bNote.addChangeListener(this);
        ((JSpinner.DefaultEditor) bThreshold.getEditor()).getTextField().setBackground(java.awt.Color.WHITE);
        ((JSpinner.DefaultEditor) bThreshold.getEditor()).getTextField().setForeground(java.awt.Color.BLACK);
        bThreshold.addChangeListener(this);

        //add popup slider to fields with high value ranges
        new PopupSlider(note_H);
        new PopupSlider(note_R);
        new PopupSlider(threshold_H);
        new PopupSlider(threshold_R);
        new PopupSlider(highLvl_H);
        new PopupSlider(highLvl_R);
        new PopupSlider(retrigger_H);
        new PopupSlider(retrigger_R);
        new PopupSlider(minScan_H);
        new PopupSlider(minScan_R);
        new PopupSlider(bNote);
        new PopupSlider(bThreshold);

        //add action listeners
        bNote.addChangeListener(this);
    }

    //set value for a field
    public void setValue(int head, int field, int value) {
        if (head >= 0 && head <= 1 && field >= 0 && field < Common.NUMBER_OF_SUBPAD_PARAMETERS) {
            ((CustomSpinnerModel) parameter[head][field].getModel()).setIntValue(value);
        } else if (head == Common.THIRDZONE && field == Common.BNOTE) {
            ((CustomSpinnerModel) bNote.getModel()).setIntValue(value);
        } else if (head == Common.THIRDZONE && field == Common.BTHRESHOLD && bThreshold.isEnabled()) {
            ((CustomSpinnerModel) bThreshold.getModel()).setIntValue(value);
        }
    }
    //get value from a field

    public int getValue(int head, int field) {
        if (head >= 0 && head <= 1 && field >= 0 && field < Common.NUMBER_OF_SUBPAD_PARAMETERS) {
            return ((CustomSpinnerModel) parameter[head][field].getModel()).getIntValue();
        } else if (head == Common.THIRDZONE && field == Common.BNOTE) {
            return ((CustomSpinnerModel) bNote.getModel()).getIntValue();
        } else if (head == Common.THIRDZONE && field == Common.BTHRESHOLD) {
            return ((CustomSpinnerModel) bThreshold.getModel()).getIntValue();
        } else {
            return -1;
        }
    }
    //set value for a field

    public void setInputNumber(int value) {
        inputNumber = value;
    }
    //get value from a field

    public int getInputNumber() {
        return inputNumber;
    }

    public void setSubpadName(int which, String n) {
        //configure subpad's names and panels
        if (padType == Common.MONO_PAD) { //MONO PAD
            if (which == Common.MONO) {
                rimName = n;
                ((TitledBorder) rimPanel.getBorder()).setTitle("Mono (" + rimName + ")");
            }
        } else { //STEREO PAD
            if (which == Common.HEAD) {
                headName = n;
                ((TitledBorder) headPanel.getBorder()).setTitle("Head (" + headName + ")");
            } else {
                rimName = n;
                ((TitledBorder) rimPanel.getBorder()).setTitle("Rim (" + rimName + ")");
            }
        }
    }

    public String getSubpadName(int which) {
        if (which == Common.HEAD) {
            return headName;
        } else {
            return rimName;
        }
    }
    //get the rim note configured in the Rim input of the stereo pad

    public int getRimNote1() {
        if (padType == Common.STEREO_PAD && ((CustomSpinnerModel) dualHeadType_H.getModel()).getIntValue() > 0) {
            return ((CustomSpinnerModel) note_R.getModel()).getIntValue();
        } else {
            return -1;
        }

    }
    //get the 3rd zone (rim) note

    public int getRimNote2() {
        if (padType == Common.STEREO_PAD && ((CustomSpinnerModel) dualHeadType_H.getModel()).getIntValue() > 0 && ((CustomSpinnerModel) dualHeadType_R.getModel()).getIntValue() == 1) {
            return ((CustomSpinnerModel) bNote.getModel()).getIntValue();
        } else {
            return -1;
        }
    }
/*
    public void convertSysexToData(byte sysex[], int subpad) {

        try {
            Method m = megadrum.gui.HihatPanel.class.getMethod("convertSysexToDataOld", new Class[]{byte[].class, int.class});
            m.invoke(this, sysex, subpad);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public byte[] convertDataToSysex(int subpad) {
        byte[] b = new byte[0];
        try {
            Method m = megadrum.gui.HihatPanel.class.getMethod("convertDataToSysexOld", new Class[]{int.class});
            b = (byte[]) m.invoke(this, subpad);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return b;
    }
*/
    //method for converting received sysex data to values and set them in the GUI fields
    public void convertSysexToData(byte sysex[], int subpad) {
        if (subpad == Common.THIRDZONE) {
            if (sysex.length == Common.LENGTH_3ZONE && sysex[3] == Common.TYPE_3ZONE && (int) sysex[4] == ((inputNumber + 1 - Common.NUMBER_OF_MONO_PADS) / 2 - 1)) { //3zone config sysex must be 10 bytes long
                tempDisableStateChangedEvents = true; //to avoid stateChanged method to be executed
                ((CustomSpinnerModel) bNote.getModel()).setIntValue(Converter.twoBytesToOneInt(sysex[5], sysex[6]));
                ((CustomSpinnerModel) bThreshold.getModel()).setIntValue(Converter.twoBytesToOneInt(sysex[7], sysex[8]));
                tempDisableStateChangedEvents = false; //enable again stateChanged events
            }
        } else {
            if (sysex.length == Common.LENGTH_PAD && sysex[3] == Common.TYPE_PAD && (int) sysex[4] == ((padType == Common.MONO_PAD) ? (inputNumber) : (inputNumber + subpad))) {
                tempDisableStateChangedEvents = true; //to avoid stateChanged method to be executed
                ((CustomSpinnerModel) parameter[subpad][Common.NOTE].getModel()).setIntValue(Converter.twoBytesToOneInt(sysex[5], sysex[6]));
                ((CustomSpinnerModel) parameter[subpad][Common.CHANNEL].getModel()).setIntValue((int) sysex[7] + 1);
                ((CustomSpinnerModel) parameter[subpad][Common.CURVE].getModel()).setIntValue((int) sysex[8]);
                ((CustomSpinnerModel) parameter[subpad][Common.COMPRLVL].getModel()).setIntValue(Converter.getIntFromBitsInByte(sysex[24], 3));
                boolean b[] = new boolean[3];
                b[0] = Converter.intToBits(sysex[23], 2)[0];
                b[1] = Converter.intToBits(sysex[23], 2)[1];
                b[2] = Converter.intToBits(sysex[24], 4)[0];
                ((CustomSpinnerModel) parameter[subpad][Common.LVLSHIFT].getModel()).setIntValue(Converter.bitsToInt(b));
                ((CustomSpinnerModel) parameter[subpad][Common.XTALK].getModel()).setIntValue(Converter.getIntFromBitsInByte(sysex[22], 2));
                ((CustomSpinnerModel) parameter[subpad][Common.XTALKGRP].getModel()).setIntValue(Converter.getIntFromBitsInByte(sysex[23], 4, 2));
                ((CustomSpinnerModel) parameter[subpad][Common.THRESHOLD].getModel()).setIntValue(Converter.twoBytesToOneInt(sysex[9], sysex[10]));
                ((CustomSpinnerModel) parameter[subpad][Common.GAIN].getModel()).setIntValue(sysex[19]);
                ((CustomSpinnerModel) parameter[subpad][Common.HILVLAUTO].getModel()).setIntValue(Converter.getIntFromBitInByte(sysex[20], 1));
                ((CustomSpinnerModel) parameter[subpad][Common.HIGHLVL].getModel()).setIntValue(Converter.fourBytesToOneInt(sysex[13], sysex[14], sysex[15], sysex[16]));
                ((CustomSpinnerModel) parameter[subpad][Common.RETRIGGER].getModel()).setIntValue(Converter.twoBytesToOneInt(sysex[11], sysex[12]));
                ((CustomSpinnerModel) parameter[subpad][Common.DYNLEVEL].getModel()).setIntValue(Converter.getIntFromBitsInByte(sysex[21], 3));
                ((CustomSpinnerModel) parameter[subpad][Common.DYNTIME].getModel()).setIntValue(Converter.getIntFromBitsInByte(sysex[22], 4, 2));
                ((CustomSpinnerModel) parameter[subpad][Common.MINSCAN].getModel()).setIntValue(Converter.twoBytesToOneInt(sysex[17], sysex[18]));
                //only apply type of input if not a mono pad (mono pads will always be type=Piezo by default)
                if (padType != Common.MONO_PAD) {
                    //for heads, set No, Yes or 3Way
                    if (subpad == Common.HEAD) {
                        ((CustomSpinnerModel) parameter[subpad][Common.DUALHEADTYPE].getModel()).setIntValue(Converter.getIntFromBitsInByte(sysex[20], 4, 2));
                    //for rims, set Piezo or Switch
                    } else {
                        ((CustomSpinnerModel) parameter[subpad][Common.DUALHEADTYPE].getModel()).setIntValue(Converter.getIntFromBitInByte(sysex[20], 0));
                    }
                }
                tempDisableStateChangedEvents = false; //enable again stateChanged events
            }
        }
    }
    //method for converting values in the GUI to a sysex message ready to be sent

    public byte[] convertDataToSysex(int subpad) {//subpad = 0 (for head) or subpad = 1 (for rim/mono)
        byte[] sysex = null;

        byte[] tempByte;
        boolean[] tempBits;

        if (subpad == Common.THIRDZONE) { //third zone

            sysex = new byte[Common.LENGTH_3ZONE];
            sysex[0] = Common.SYSEX_BEGIN;
            sysex[1] = Common.SYSEX_ID;
            sysex[2] = (byte) parent.getChainID();
            sysex[3] = Common.TYPE_3ZONE;
            sysex[4] = (byte) ((inputNumber + 1 - Common.NUMBER_OF_MONO_PADS) / 2 - 1);
            tempByte = Converter.intToTwoBytes(((CustomSpinnerModel) bNote.getModel()).getIntValue());
            sysex[5] = tempByte[0];
            sysex[6] = tempByte[1];
            tempByte = Converter.intToTwoBytes(((CustomSpinnerModel) bThreshold.getModel()).getIntValue());
            sysex[7] = tempByte[0];
            sysex[8] = tempByte[1];
            sysex[9] = Common.SYSEX_END;

        } else { //head or rim (or mono)

            sysex = new byte[Common.LENGTH_PAD];
            sysex[0] = Common.SYSEX_BEGIN;
            sysex[1] = Common.SYSEX_ID;
            sysex[2] = (byte) parent.getChainID();
            sysex[3] = Common.TYPE_PAD;
            sysex[4] = (byte) ((padType == Common.MONO_PAD) ? (inputNumber) : (inputNumber + subpad));
            tempByte = Converter.intToTwoBytes(((CustomSpinnerModel) parameter[subpad][Common.NOTE].getModel()).getIntValue());
            sysex[5] = tempByte[0];
            sysex[6] = tempByte[1];
            sysex[7] = (byte) (((CustomSpinnerModel) parameter[subpad][Common.CHANNEL].getModel()).getIntValue() - 1);
            sysex[8] = (byte) ((CustomSpinnerModel) parameter[subpad][Common.CURVE].getModel()).getIntValue();
            tempByte = Converter.intToTwoBytes(((CustomSpinnerModel) parameter[subpad][Common.THRESHOLD].getModel()).getIntValue());
            sysex[9] = tempByte[0];
            sysex[10] = tempByte[1];
            tempByte = Converter.intToTwoBytes(((CustomSpinnerModel) parameter[subpad][Common.RETRIGGER].getModel()).getIntValue());
            sysex[11] = tempByte[0];
            sysex[12] = tempByte[1];
            tempByte = Converter.intToFourBytes(((CustomSpinnerModel) parameter[subpad][Common.HIGHLVL].getModel()).getIntValue());
            sysex[13] = tempByte[0];
            sysex[14] = tempByte[1];
            sysex[15] = tempByte[2];
            sysex[16] = tempByte[3];
            tempByte = Converter.intToFourBytes(((CustomSpinnerModel) parameter[subpad][Common.MINSCAN].getModel()).getIntValue());
            sysex[17] = tempByte[0];
            sysex[18] = tempByte[1];
            sysex[19] = (byte) ((CustomSpinnerModel) parameter[subpad][Common.GAIN].getModel()).getIntValue();
            if (subpad == Common.HEAD) {
                sysex[20] = Converter.bitsToNibble(
                        ((CustomSpinnerModel) parameter[subpad][Common.DUALHEADTYPE].getModel()).getIntValue() == 2,
                        ((CustomSpinnerModel) parameter[subpad][Common.DUALHEADTYPE].getModel()).getIntValue() == 1,
                        ((CustomSpinnerModel) parameter[subpad][Common.HILVLAUTO].getModel()).getIntValue() != 0,
                        false);
            } else {
                sysex[20] = Converter.bitsToNibble(
                        false,
                        false,
                        ((CustomSpinnerModel) parameter[subpad][Common.HILVLAUTO].getModel()).getIntValue() != 0,
                        ((CustomSpinnerModel) parameter[subpad][Common.DUALHEADTYPE].getModel()).getIntValue() != 0);
            }
            sysex[21] = (byte) (((CustomSpinnerModel) parameter[subpad][Common.DYNLEVEL].getModel()).getIntValue() & 0x07);
            sysex[22] = Converter.bitsToNibble(
                    ((CustomSpinnerModel) parameter[subpad][Common.DYNTIME].getModel()).getIntValue() > 1,
                    ((CustomSpinnerModel) parameter[subpad][Common.DYNTIME].getModel()).getIntValue() % 2 == 1,
                    ((CustomSpinnerModel) parameter[subpad][Common.XTALK].getModel()).getIntValue() > 1,
                    ((CustomSpinnerModel) parameter[subpad][Common.XTALK].getModel()).getIntValue() % 2 == 1);
            sysex[23] = Converter.bitsToNibble(
                    ((CustomSpinnerModel) parameter[subpad][Common.XTALKGRP].getModel()).getIntValue() > 1,
                    ((CustomSpinnerModel) parameter[subpad][Common.XTALKGRP].getModel()).getIntValue() % 2 == 1,
                    ((CustomSpinnerModel) parameter[subpad][Common.LVLSHIFT].getModel()).getIntValue() > 3,
                    ((CustomSpinnerModel) parameter[subpad][Common.LVLSHIFT].getModel()).getIntValue() % 4 > 1);
            tempBits = Converter.intToBits(((CustomSpinnerModel) parameter[subpad][Common.COMPRLVL].getModel()).getIntValue(), 3);
            sysex[24] = Converter.bitsToNibble(
                    ((CustomSpinnerModel) parameter[subpad][Common.LVLSHIFT].getModel()).getIntValue() % 2 == 1,
                    tempBits[0],
                    tempBits[1],
                    tempBits[2]);
            sysex[25] = Common.SYSEX_END;

        }
        return sysex;
    }

    public void stateChanged(ChangeEvent evt) {
        if (evt.getSource() == bNote) {
            //if 3rd zone note is set to Disabled, then set Threshold to 0
            if (getValue(Common.THIRDZONE, Common.BNOTE) == 0) {
                setValue(Common.THIRDZONE, Common.BTHRESHOLD, 0);
                bThreshold.setEnabled(false);
            } else {
                bThreshold.setEnabled(true);
            }
        }
        if (!tempDisableStateChangedEvents) {
            //Some parameter has been changed, if Live Editing is enabled, schedule a sending
            if(parent.getLiveEditingEnabled()){
                parent.scheduleSending(Common.PAD_EVENT, parent.getCurrentSelectedPad());
            }
        }
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JSpinner bNote;
    private javax.swing.JSpinner bThreshold;
    private javax.swing.JSpinner channel_H;
    private javax.swing.JSpinner channel_R;
    private javax.swing.JSpinner comprLvl_H;
    private javax.swing.JSpinner comprLvl_R;
    private javax.swing.JSpinner curve_H;
    private javax.swing.JSpinner curve_R;
    private javax.swing.JSpinner dualHeadType_H;
    private javax.swing.JSpinner dualHeadType_R;
    private javax.swing.JSpinner dynLevel_H;
    private javax.swing.JSpinner dynLevel_R;
    private javax.swing.JSpinner dynTime_H;
    private javax.swing.JSpinner dynTime_R;
    private javax.swing.JSpinner gain_H;
    private javax.swing.JSpinner gain_R;
    private javax.swing.JPanel headPanel;
    private javax.swing.JSpinner hiLvlAuto_H;
    private javax.swing.JSpinner hiLvlAuto_R;
    private javax.swing.JSpinner highLvl_H;
    private javax.swing.JSpinner highLvl_R;
    private javax.swing.JSpinner lvlShift_H;
    private javax.swing.JSpinner lvlShift_R;
    private javax.swing.JSpinner minScan_H;
    private javax.swing.JSpinner minScan_R;
    private javax.swing.JSpinner note_H;
    private javax.swing.JSpinner note_R;
    private javax.swing.JSpinner retrigger_H;
    private javax.swing.JSpinner retrigger_R;
    private javax.swing.JPanel rimPanel;
    private javax.swing.JPanel thirdZonePanel;
    private javax.swing.JSpinner threshold_H;
    private javax.swing.JSpinner threshold_R;
    private javax.swing.JSpinner xtalkGrp_H;
    private javax.swing.JSpinner xtalkGrp_R;
    private javax.swing.JSpinner xtalk_H;
    private javax.swing.JSpinner xtalk_R;
    // End of variables declaration//GEN-END:variables
    private MegadrumConfigTool parent;
    private String headName,  rimName;
    private JSpinner parameter[][];
    private int padType,  inputNumber;
    private boolean tempDisableStateChangedEvents = false;
}
